package de.tabuma.wsdl2xform.xform.view;

import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;
import de.tabuma.lib.tabumaview;
import de.tabuma.wsdl2xform.xform.*;

/**
 * @author $Author: alefen $
 * @version $Revision: 1.3 $
 * @since $Date: 2009/12/30 01:10:56 $
 */
public class view extends tabumaview {

    private static Logger log = Logger.getLogger(view.class.getName());

    public view(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out)  {
        try {
            int navInt = constants.NAV_NULL;
            if(request.getAttribute(constants.XFORM_NAV)!=null) {
                navInt = Integer.valueOf((String)request.getAttribute(constants.XFORM_NAV));
            }

            switch(navInt) {
                case constants.NAV_NULL:
                    log.fine("Giving focus to "+projectOverview.class.getName());
                    projectOverview projectoverview = new projectOverview(this.getServlet(), this.getParameter());
                    projectoverview.processRequest(context, request, response, out);
                    break;

                case constants.NAV_FIRST_STEP:
                    log.fine("Giving focus to "+projectPage1.class.getName());
                    projectPage1 pp1 = new projectPage1(this.getServlet(), this.getParameter());
                    pp1.processRequest(context, request, response, out);
                    break;

                case constants.NAV_SECOND_STEP:
                    log.fine("Giving focus to "+projectPage2.class.getName());
                    projectPage2 pp2 = new projectPage2(this.getServlet(), this.getParameter());
                    pp2.processRequest(context, request, response, out);
                    break;

                case constants.NAV_SHOW_PROJECT:
                    log.fine("Giving focus to "+projectPage3.class.getName());
                    projectPage3 pp3 = new projectPage3(this.getServlet(), this.getParameter());
                    pp3.processRequest(context, request, response, out);
                    break;
            }
        } 
        catch(Exception e) {
            log.warning(e.getMessage());
        }
    }
}